package at.ac.tuwien.mg.bean;

import java.io.Serializable;
import java.util.List;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Offer implements Serializable {

	private static final long serialVersionUID = -1716091639123401964L;
	private Supplier supplier;
	@Override
	public String toString() {
		return "Offer [supplier=" + supplier + ", total=" + total + ", items="
				+ items + ", returnAdress=" + returnAdress
				+ ", processInstanceId=" + processInstanceId + ", ranking=" + ranking +  "]";
	}

	private double total;
	private List<Item> items;
	private String returnAdress;
	private String processInstanceId;
	private int ranking;
	
	public Offer() {
		this.ranking = 0;
	}
	
	public Offer(Supplier supplier, List<Item> items) {
		this.supplier = supplier;
		this.items = items;
		
		double sum = 0.0;
		for(Item i : items) {
			sum += i.getPrice() * i.getAmount();
		}
		this.total = sum;
		
		this.ranking = 0;
	}
	
	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public double getTotal() {
		return total;
	}

	public void setTotal(double total) {
		this.total = total;
	}

	public List<Item> getItems() {
		return items;
	}

	public void setItems(List<Item> items) {
		this.items = items;
	}

	public String getReturnAdress() {
		return returnAdress;
	}

	public void setReturnAdress(String returnAdress) {
		this.returnAdress = returnAdress;
	}

	public String getProcessInstanceId() {
		return processInstanceId;
	}

	public void setProcessInstanceId(String processInstanceId) {
		this.processInstanceId = processInstanceId;
	}

	public int getRanking() {
		return ranking;
	}

	public void setRanking(int ranking) {
		this.ranking = ranking;
	}
}
